package com.kang.controller;

import com.kang.feign.UserFeignClient;
import com.kang.service.LargeScreenService;
import com.kang.util.WebResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

/**
 * @Author: 康康
 * @Date: 2023/03/26/22:24
 */
@Api(tags = "大屏展示")
@RestController
@RequestMapping("/admin/largeScreen")
@Slf4j
public class LargeScreenController {

    @Autowired
    private LargeScreenService largeScreenService;

    @Autowired
    private UserFeignClient userFeignClient;

    @ApiOperation("个人信息")
    @GetMapping("getUser")
    public WebResponse getUser() {
        try {
            return WebResponse.resSuccess("个人查询信息成功",largeScreenService.getUser());
        } catch (Exception ex) {
            log.error("个人信息查询失败",ex);
            return WebResponse.resFail("个人查询失败",null);
        }
    }

    @ApiOperation("热榜统计")
    @GetMapping("getHotEssay")
    public WebResponse getHotEssay() {
        try {
            return WebResponse.resSuccess("热榜统计成功",userFeignClient.getHotEssay());
        } catch (Exception ex) {
            log.error("热榜统计失败",ex);
            return WebResponse.resFail("热榜统计失败",null);
        }
    }

    @ApiOperation("统计信息")
    @GetMapping("getMessage")
    public WebResponse getMessage() {
        try {
            return WebResponse.resSuccess("统计信息成功",largeScreenService.getMessage());
        } catch (Exception ex) {
            log.error("统计信息失败",ex);
            return WebResponse.resFail("统计信息失败",null);
        }
    }

    @ApiOperation("树状图")
    @GetMapping("getSeriesDate")
    public WebResponse getSeriesDate() {
        try {
            return WebResponse.resSuccess("统计树状图成功",largeScreenService.getSeriesDate());
        } catch (Exception ex) {
            log.error("统计树状图失败",ex);
            return WebResponse.resFail("统计树状图失败",null);
        }
    }

    @ApiOperation("饼状图")
    @GetMapping("getLabelLine")
    public WebResponse getLabelLine(String value) {
        try {
            return WebResponse.resSuccess("统计饼状图成功",largeScreenService.getLabelLine(value));
        } catch (Exception ex) {
            log.error("统计饼状图失败",ex);
            return WebResponse.resFail("统计饼状图失败",null);
        }
    }


}
